load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test")
load("@io_bazel_rules_go//proto:compiler.bzl", "go_proto_compiler")

package(default_visibility = ["//visibility:private"])

go_library(
    name = "protoc-gen-grpc-gateway_lib",
    srcs = ["main.go"],
    importpath = "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway",
    deps = [
        "//internal/codegenerator",
        "//internal/descriptor",
        "//protoc-gen-grpc-gateway/internal/gengateway",
        "@com_github_golang_glog//:glog",
        "@org_golang_google_protobuf//compiler/protogen",
    ],
)

go_binary(
    name = "protoc-gen-grpc-gateway",
    embed = [":protoc-gen-grpc-gateway_lib"],
    visibility = ["//visibility:public"],
)

go_proto_compiler(
    name = "go_gen_grpc_gateway",
    options = [
        "logtostderr=true",
        "allow_repeated_fields_in_body=true",
    ],
    plugin = ":protoc-gen-grpc-gateway",
    suffix = ".pb.gw.go",
    visibility = ["//visibility:public"],
    deps = [
        "//runtime:go_default_library",
        "//utilities:go_default_library",
        "@org_golang_google_grpc//:go_default_library",
        "@org_golang_google_grpc//codes:go_default_library",
        "@org_golang_google_grpc//grpclog:go_default_library",
        "@org_golang_google_grpc//metadata:go_default_library",
        "@org_golang_google_grpc//status:go_default_library",
        "@org_golang_google_protobuf//proto:go_default_library",
    ],
)

go_test(
    name = "protoc-gen-grpc-gateway_test",
    srcs = ["main_test.go"],
    embed = [":protoc-gen-grpc-gateway_lib"],
    deps = ["//internal/descriptor"],
)
